<template>
        <div style="box-shadow: 5px 5px 10px 0px  rgba(0, 0, 0, 0.2);height: 600px;width: 800px; background-color: #fafafa; position: absolute; left: 55%; top: 55%; transform: translate(-50%,-50%);
    padding: 20px; 
    ">
        <h2>注册商家</h2>
        <el-divider />
        <br/>
    <el-form :model="business">
      <el-form-item label="Account" >
        <el-input v-model="business.account" autocomplete="off" />
      </el-form-item>
      <el-form-item label="Password" >
        <el-input v-model="business.password" autocomplete="off" />
      </el-form-item>

        <el-form-item label="telePhone" >
            <el-input v-model="business.telephone" autocomplete="off" />
      </el-form-item>
      <el-form-item label="contact" >
        <el-input v-model="business.contact" autocomplete="off" />
      </el-form-item>

    </el-form>

    <el-divider />
    <el-button type="primary" @click="foodAdd(business)">注册商家</el-button>
    
  </div>
</template>

<script setup>

import { ref } from 'vue'
import { ElMessage } from 'element-plus'
import axios from 'axios'
import { useRouter } from 'vue-router'
const business = ref({})
const router = useRouter();
const foodAdd = (business) => {
  console.log(business)
  axios.post('http://localhost:7444/business/addBusiness',business).then((response)=>{
    if(response.data.code==200){
      ElMessage({
        message: '注册成功',
        type: 'success',
      });
      router.push({ path: '/businessList' })
    }
  })
}
</script>

<style lang="scss" scoped>

</style>